home *** CD-ROM | disk | FTP | other *** search
- Path: holly.ACNS.ColoState.EDU!not-for-mail
- From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
- Newsgroups: comp.lang.c++
- Subject: Copy constructor
- Date: 11 Apr 1996 15:43:14 -0600
- Organization: Colorado State University, Fort Collins, CO 80523
- Message-ID: <4kjudi$2qj0@holly.ACNS.ColoState.EDU>
- NNTP-Posting-Host: holly.acns.colostate.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hi all, I'm having some trouble figuring out how to do a copy
- constructor. Here's what I thought was suppose to work:
-
- header file----
- class ABC
- {
- private:
- int AnInt;
-
- public:
- ABC():AnInt(5) {} // Default Constructor
- ~ABC() {} // Default Destructor
- ABC(const ABC&); // Copy constructor
- }
-
- ABC::ABC(const ABC& NewABC)
- {
- this->AnInt = NewABC->AnInt;
- }
-
- Unfortunatly, I can't get this to work right. I get weird messages from
- the compiler complaining about not being able to use a class definition
- as an argument. This was using xlC under IBM Aix. Any suggestions are
- greatly appreciated. Thanks.
-
-
- T E A R A L O N G T H E D O T T E D L I N E
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Corby S. Hudnall Junior, Spring 1996
- Colorado State University http://WWW.CS.ColoState.EDU/~hudnall
- Department of Computer Science hudnall@CS.ColoState.EDU
-
-